﻿using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace KonsolAntresol.Helpers
{
	public static class MenuLinkHelper
	{
		public static MvcHtmlString MenuLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string pageName)
		{
			var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action");
			var currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
			if (actionName == currentAction && controllerName == currentController)
			{
				return htmlHelper.ActionLink(
					linkText,
					actionName,
					controllerName,
					new { pageName },
					new
					{
						@class = "selected"
					});
			}
			return htmlHelper.ActionLink(linkText, actionName, controllerName, new { pageName }, null);
		}
	}
}